<?php
	//状态吗定义   stateCode  2 : 数据库连接错误;  3 : 数据库插入错误;  4 : 用户名重复;
					  
	header("Content-type:text/html;charset=utf-8");
	header('Access-Control-Allow-Origin: *');
	$username_zjj = $_POST["username_zjj"];
	$password_zjj = $_POST["password_zjj"];
	$phone_zjj = $_POST["phone_zjj"];
	$email_zjj = $_POST["email_zjj"];
	$username_hyh = $_POST["username_hyh"];
	$password_hyh = $_POST["password_hyh"];
	$phone_hyh = $_POST["phone_hyh"];
	$email_hyh = $_POST["email_hyh"];
	$username_lkk = $_POST["username_lkk"];
	$password_lkk = $_POST["password_lkk"];
	$phone_lkk = $_POST["phone_lkk"];
	$email_lkk = $_POST["email_lkk"];
	$username_xsj = $_POST["username_xsj"];
	$password_xsj = $_POST["password_xsj"];
	$phone_xsj = $_POST["phone_xsj"];
	$email_xsj = $_POST["email_xsj"];
	$username_zbw = $_POST["username_zbw"];
	$password_zbw = $_POST["password_zbw"];
	$phone_zbw = $_POST["phone_zbw"];
	$email_zbw = $_POST["email_zbw"];
	$username_zww = $_POST["username_zww"];
	$password_zww = $_POST["password_zww"];
	$phone_zww = $_POST["phone_zww"];
	$email_zww = $_POST["email_zww"];
	$username_yzm = $_POST["username_yzm"];
	$password_yzm = $_POST["password_yzm"];
	$phone_yzm = $_POST["phone_yzm"];
	$email_yzm = $_POST["email_yzm"];
	//定义数据库链接参数
	$db_host = "localhost:3306";
	$db_username = "root";
	$db_password = "123456";
	//开始链接数据库，返回连接结果
	$con = mysql_connect($db_host,$db_username,$db_password);
	//条件判断数据库是否链接成功
	if(!$con){
		$json_arr = array("statu" => "error","stateCode" => "2","errType" => "mysql error".mysql_error());
		die(json_encode($json_arr));
	}
	//链接到操作的数据库
	mysql_select_db("group7",$con);
	//插入数据库之前进行重复数据校验
	if($username_zjj !== null && $password_zjj !== null){
		$query_sql = "select count(*) from user_zjj where username_zjj = '$username_zjj'";
		$select_res = mysql_query($query_sql,$con);
		if(mysql_result($select_res,0) >=1){
			$json_arr = array("statu" => "error","stateCode" => "4","errType" => "repeat of user name");
			die(json_encode($json_arr));
		}
		//开始插入数据
		//密码进行加密处理
		$password_zjj = md5($password_zjj);
		$inser_sql = "insert into user_zjj (`username_zjj`,`password_zjj`,`phone_zjj`,`email_zjj`) values ('$username_zjj','$password_zjj','$phone_zjj','$email_zjj')";
		$insert_res = mysql_query($inser_sql,$con);
		if(!$insert_res){
			$json_arr = array("statu" => "error","stateCode" => "3","errType" => "mysql error".mysql_error());
			die(json_encode($json_arr));
		}
		$json_arr = array( "statu" => "success" , "stateCode" => "1" , "password" => md5($password_zjj));
		echo json_encode($json_arr);
		
	}elseif($username_hyh !== null && $password_hyh !== null){
		$query_sql = "select count(*) from user_hyh where username_hyh = '$username_hyh'";
		$select_res = mysql_query($query_sql,$con);
		if(mysql_result($select_res,0) >=1){
			$json_arr = array("statu" => "error","stateCode" => "4","errType" => "repeat of user name");
			die(json_encode($json_arr));
		}
		//开始插入数据
		//密码进行加密处理
		$password_hyh = md5($password_hyh);
		$inser_sql = "insert into user_hyh (`username_hyh`,`password_hyh`,`phone_hyh`,`email_hyh`) values ('$username_hyh','$password_hyh','$phone_hyh','$email_hyh')";
		$insert_res = mysql_query($inser_sql,$con);
		if(!$insert_res){
			$json_arr = array("statu" => "error","stateCode" => "3","errType" => "mysql error".mysql_error());
			die(json_encode($json_arr));
		}
		$json_arr = array( "statu" => "success" , "stateCode" => "1" , "password" => md5($password_hyh));
		echo json_encode($json_arr);
	}elseif($username_lkk !== null && $password_lkk !== null){
		$query_sql = "select count(*) from user_lkk where username_lkk = '$username_lkk'";
		$select_res = mysql_query($query_sql,$con);
		if(mysql_result($select_res,0) >=1){
			$json_arr = array("statu" => "error","stateCode" => "4","errType" => "repeat of user name");
			die(json_encode($json_arr));
		}
		//开始插入数据
		//密码进行加密处理
		$password_lkk = md5($password_lkk);
		$inser_sql = "insert into user_lkk (`username_lkk`,`password_lkk`,`phone_lkk`,`email_lkk`) values ('$username_lkk','$password_lkk','$phone_lkk','$email_lkk')";
		$insert_res = mysql_query($inser_sql,$con);
		if(!$insert_res){
			$json_arr = array("statu" => "error","stateCode" => "3","errType" => "mysql error".mysql_error());
			die(json_encode($json_arr));
		}
		$json_arr = array( "statu" => "success" , "stateCode" => "1" , "password" => md5($password_lkk));
		echo json_encode($json_arr);
	}elseif($username_xsj !== null && $password_xsj !== null){
		$query_sql = "select count(*) from user_xsj where username_xsj = '$username_xsj'";
		$select_res = mysql_query($query_sql,$con);
		if(mysql_result($select_res,0) >=1){
			$json_arr = array("statu" => "error","stateCode" => "4","errType" => "repeat of user name");
			die(json_encode($json_arr));
		}
		//开始插入数据
		//密码进行加密处理
		$password_xsj = md5($password_xsj);
		$inser_sql = "insert into user_zjj (`username_xsj`,`password_xsj`,`phone_xsj`,`email_xsj`) values ('$username_xsj','$password_xsj','$phone_xsj','$email_xsj')";
		$insert_res = mysql_query($inser_sql,$con);
		if(!$insert_res){
			$json_arr = array("statu" => "error","stateCode" => "3","errType" => "mysql error".mysql_error());
			die(json_encode($json_arr));
		}
		$json_arr = array( "statu" => "success" , "stateCode" => "1" , "password" => md5($password_xsj));
		echo json_encode($json_arr);
	}elseif($username_zbw !== null && $password_zbw !== null){
		$query_sql = "select count(*) from user_zbw where username_zbw = '$username_zbw'";
		$select_res = mysql_query($query_sql,$con);
		if(mysql_result($select_res,0) >=1){
			$json_arr = array("statu" => "error","stateCode" => "4","errType" => "repeat of user name");
			die(json_encode($json_arr));
		}
		//开始插入数据
		//密码进行加密处理
		$password_zbw = md5($password_zbw);
		$inser_sql = "insert into user_zbw (`username_zbw`,`password_zbw`,`phone_zbw`,`email_zbw`) values ('$username_zbw','$password_zbw','$phone_zbw','$email_zbw')";
		$insert_res = mysql_query($inser_sql,$con);
		if(!$insert_res){
			$json_arr = array("statu" => "error","stateCode" => "3","errType" => "mysql error".mysql_error());
			die(json_encode($json_arr));
		}
		$json_arr = array( "statu" => "success" , "stateCode" => "1" , "password" => md5($password_zbw));
		echo json_encode($json_arr);
	}elseif($username_zww !== null && $password_zww !== null){
		$query_sql = "select count(*) from user_zww where username_zww = '$username_zww'";
		$select_res = mysql_query($query_sql,$con);
		if(mysql_result($select_res,0) >=1){
			$json_arr = array("statu" => "error","stateCode" => "4","errType" => "repeat of user name");
			die(json_encode($json_arr));
		}
		//开始插入数据
		//密码进行加密处理
		$password_zww = md5($password_zww);
		$inser_sql = "insert into user_zww (`username_zww`,`password_zww`,`phone_zww`,`email_zww`) values ('$username_zww','$password_zww','$phone_zww','$email_zww')";
		$insert_res = mysql_query($inser_sql,$con);
		if(!$insert_res){
			$json_arr = array("statu" => "error","stateCode" => "3","errType" => "mysql error".mysql_error());
			die(json_encode($json_arr));
		}
		$json_arr = array( "statu" => "success" , "stateCode" => "1" , "password" => md5($password_zww));
		echo json_encode($json_arr);
	}elseif($username_yzm !== null && $password_yzm !== null){
		$query_sql = "select count(*) from user_yzm where username_yzm = '$username_yzm'";
		$select_res = mysql_query($query_sql,$con);
		if(mysql_result($select_res,0) >=1){
			$json_arr = array("statu" => "error","stateCode" => "4","errType" => "repeat of user name");
			die(json_encode($json_arr));
		}
		//开始插入数据
		//密码进行加密处理
		$password_yzm = md5($password_yzm);
		$inser_sql = "insert into user_yzm (`username_yzm`,`password_yzm`,`phone_yzm`,`email_yzm`) values ('$username_yzm','$password_yzm','$phone_yzm','$email_yzm')";
		$insert_res = mysql_query($inser_sql,$con);
		if(!$insert_res){
			$json_arr = array("statu" => "error","stateCode" => "3","errType" => "mysql error".mysql_error());
			die(json_encode($json_arr));
		}
		$json_arr = array( "statu" => "success" , "stateCode" => "1" , "password" => md5($password_yzm));
		echo json_encode($json_arr);
	}
	
?>

